<template>
  <div class="main_box">
    <div class="add_wrap">
      <el-form label-width="200px">
        <div class="tit">
        <h2>医院医检信息</h2>
        <el-button
          plain
          size="small"
          type="success"
          icon="fa fa-mail-forward"
          @click="returnList"
        >
          返 回</el-button
        >
      </div>
        <el-row>
          <el-form-item label="医院:" v-if="reportData.hospitalName">
            <span>{{reportData.hospitalName}}</span>
          </el-form-item>
          <el-form-item label="医院科室:" v-if="reportData.officeName">
            <span>{{reportData.officeName}}</span>
          </el-form-item>
          <el-form-item label="医生:" v-if="reportData.doctorName">
            <span>{{reportData.doctorName}}</span>
          </el-form-item>
          <el-form-item label="医检机构:" v-if="reportData.institutionName">
            <span>{{reportData.institutionName}}</span>
          </el-form-item>
          <el-form-item label="医检科室:" v-if="reportData.insOfficeName">
            <span>{{reportData.insOfficeName}}</span>
          </el-form-item>
        </el-row>
        <div class="tit">
          <h2>基础信息</h2>
        </div>
        <el-row>
          <el-form-item label="编号:">
            <span>{{reportData.reportCode}}</span>
          </el-form-item>
          <el-form-item label="平台条码号:">
            <span>{{reportData.myReportCode}}</span>
          </el-form-item>
          <el-form-item label="医检条码号:">
            <span>{{reportData.insReportCode}}</span>
          </el-form-item>
          <el-form-item label="送检项目:">
            <span>{{reportData.itemName}}</span>
          </el-form-item>
          <!-- <el-form-item label="查询号:">
            <span>{{reportData.searchCode}}</span>
          </el-form-item> -->
          <el-form-item label="是否需要结果提醒:">
            <span>{{formatRemind(reportData.isRemind)}}</span>
          </el-form-item>
          <el-form-item label="当前收样员:">
            <span>{{reportData.syUserName}}({{reportData.syUserLevel}}级)</span>
          </el-form-item>
          <el-form-item label="所有收样员:">
            <span>{{reportData.syUserNames}}</span>
          </el-form-item>
          <el-form-item label="送检时间:">
            <span>{{reportData.reportBeginTime}}</span>
          </el-form-item>
          <el-form-item label="已出报告时间:">
            <span>{{reportData.reportEndTime}}</span>
          </el-form-item>
          <el-form-item label="上传结果用户名:">
            <span>{{reportData.uploadUserName}}</span>
          </el-form-item>
          <el-form-item label="报告单状态:">
            <span>{{formatReportState(reportData.reportState)}}</span>
          </el-form-item>
          <el-form-item label="上机状态:">
            <span>{{formatTransmitState(reportData.transmitState)}}</span>
          </el-form-item>
          <el-form-item label="异常状态:">
            <span>{{formatAbnormalState(reportData.abnormalState)}}</span>
          </el-form-item>
          <el-form-item label="财务备注:">
            <span>{{reportData.financeRemark}}</span>
          </el-form-item>
          <el-form-item label="备注:">
            <span>{{reportData.remark}}</span>
          </el-form-item>
          <el-form-item label="创建人:">
            <span>{{ reportData.createUserName}}</span>
          </el-form-item>
          <el-form-item label="创建时间:">
            <span>{{ reportData.createDate }}</span>
          </el-form-item>
          <el-form-item label="修改人:">
            <span>{{ reportData.modifyUserName}}</span>
          </el-form-item>
          <el-form-item label="修改时间:">
            <span>{{ reportData.modifyDate }}</span>
          </el-form-item>
        </el-row>
        <div class="tit">
          <h2>患者信息</h2>
        </div>
        <el-row>
          <el-form-item label="患者姓名:">
            <span>{{reportData.patientName}}</span>
          </el-form-item>
          <el-form-item label="患者性别:">
             <span v-if="reportData.patientSex == 1">男</span>
            <span v-else-if="reportData.patientSex == 2">女</span>
          </el-form-item>
          <el-form-item label="患者年龄:">
            <span>{{reportData.patientAge}}</span>
          </el-form-item>
          <el-form-item label="患者电话:">
            <span>{{reportData.patientPhone}}</span>
          </el-form-item>
          <el-form-item label="证件类型:">
            <span v-if="reportData.cardType == 1">居民身份证</span>
            <span v-else-if="reportData.cardType == 9">其他</span>
          </el-form-item>
          <el-form-item label="患者身份证:">
            <span>{{reportData.patientCard}}</span>
          </el-form-item>
          <el-form-item label="基本病情:">
            <span>{{reportData.patientInfo}}</span>
          </el-form-item>

        </el-row>

        
      </el-form>
    </div>

  </div>
</template>

<script>
import Map from "@/components/Map";
import ReportApi from "@/api/hsReport/hsReport";
// import "viewerjs/dist/viewer.css";
// import Viewer from "v-viewer";
// import { mapGetters, mapActions } from 'vuex'
export default {
  data() {
    return {
      reportData: ""
    };
  },
  components: {
    Map
  },
  computed: {},
  beforeRouteLeave(to, from, next) {
    to.meta.keepAlive = true;
    next();
  },
  methods: {
    getData() {
      ReportApi.getReport({ reportId: this.$route.query.id }).then(res => {
        this.reportData = res.data;
        if (res.data.syUserList && res.data.syUserList.length > 0) {
          let syUserNames = "";
          res.data.syUserList.forEach((item, index) => {
            syUserNames =
              syUserNames + item.userName + "(" + Number(index + 1) + "级) ，";
          });
          this.reportData.syUserNames = syUserNames.substr(
            0,
            syUserNames.length - 1
          );
        }
      });
    },
    formatDate(value) {
      return this.$Utils.formatDate(value, "yyyy-MM-dd");
    },
    formatRemind(value) {
      if (value == 0) {
        return "否";
      } else if (value == 1) {
        return "是";
      }
    },
    formatPrintState(cellValue) {
      if (cellValue === 0) {
        return "未打印";
      } else if (cellValue === 1) {
        return "已打印";
      }
    },
    formatAbnormalState(cellValue) {
      if (cellValue === 1) {
        return "条码号异常";
      } else if (cellValue === 2) {
        return "姓名/身份证异常";
      } else if (cellValue === 3) {
        return "年龄/性别异常";
      } else if (cellValue === 4) {
        return "多条结果";
        // }else if (cellValue === 5) {
        //   return '结果未出'
        // }else if (cellValue === 6) {
        //   return '结果时间太久，需去对于的官网查看'
      } else if (cellValue === 7) {
        return "报告单结果未全出";
      } else if (cellValue === 8) {
        return "认证错误";
      } else if(cellValue === 9){
        return "阳性"
      }
    },
    formatReportState(cellValue) {
      if (cellValue === 0) {
        return "未收取";
      } else if (cellValue === 5) {
        return "已收取";
      } else if (cellValue === 10) {
        return "已送达";
      } else if (cellValue === 12) {
        return "已收到";
      } else if (cellValue === 15) {
        return "检测中";
      }else if (cellValue === 18) {
        return "取消中";
      } else if (cellValue === 19) {
        return "已取消";
      }  else if (cellValue === 20) {
        return "已出结果";
      }
    },
    //报告单在医检处理状态（0.待接收 5.已接收 10.上机成功 14.上机失败 15.再次上机 20.已完成）
    formatTransmitState(cellValue) {
      if (cellValue === 0) {
        return "待接收";
      } else if (cellValue === 5) {
        return "已接收";
      } else if (cellValue === 10) {
        return "上机成功";
      } else if (cellValue === 14) {
        return "上机失败";
      } else if (cellValue === 15) {
        return "再次上机";
      } else if (cellValue === 19) {
        return "已取消";
      } else if (cellValue === 20) {
        return "已完成";
      }
    },
    formatSyUserLevel(index) {
      let result = this.$Utils.numberToChinese(index);
      return result + "级";
    },
    returnList() {
      this.$store.dispatch("delView", this.$route);
      this.$router.push({ path: "/hsReport/hsReportManagement" });
    }
  },
  mounted() {
    this.getData();
  }
};
</script>
<!-- <style lang="scss" src="@/assets/css/views/Detail.scss" scope></style> -->
<style lang="scss" src="@/assets/css/views/add.scss" scope></style>
